package com.fly.service.impl;

import com.fly.mapper.UsersMapper;
import com.fly.pojo.Users;
import com.fly.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;


@Service
public class UserServiceImpl implements UserService {

    @Autowired(required=false)
    public UsersMapper usersMapper;


    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public boolean queryUsernameIsExits(String username) {

        Example usersexample=new Example(Users.class);
        Example.Criteria usercriteria = usersexample.createCriteria();
        usercriteria.andEqualTo("username",username);
        Users result = usersMapper.selectOneByExample(usersexample);

        return result==null?false:true;
    }
}
